<?php
if(!$_SESSION['memberID']){
    header('Location:/new/d/shops/gtindex.html');
    exit;
}
include_once("/var/www/html/new/com.inc.php");
$id=$_SESSION['memberID'];
$sel="select headphoto from pft_member where id=$id";
$GLOBALS['le']->query($sel);
$row = $GLOBALS['le']->fetch_assoc();
include_once('/var/www/html/new/d/common/autoload.php');
$mem = new \pft\Member\MemberAccount($GLOBALS['le']);
$m_info = $mem->GetOne($_SESSION['memberID']);
$tt=array("dname","address","mobile","qq","headphoto","cname","ctel","alipay","position","email","com_name","com_type","province","city","fax","website","business","short_company_name");

$headphoto = $m_info['headphoto'] ? $m_info['headphoto']:"http://www.12301.cc/images/touxiang.png";
if(strpos('http:', $headphoto)===0){
	$headphoto = 'http://www.12301.cc/'.$headphoto;
}
?>
<? include("ggheader.php") ?>
	<link rel="stylesheet" href="http://www.12301.cc/shops/css/gmem.css"/>
	<!-- <script type="text/javascript" src="http://www.12301.cc/js/updLower.js"></script> -->
	<script type="text/javascript" src="http://www.12301.cc/js/md5.js"></script>
	<script type="text/javascript" src="http://www.12301.cc/js/chPs_gly.js" ></script>
	<div id="mask"></div>
	<div class="mem_con">
		<div class="mem_left">
			<div id="mem_photo"><a href="javascript:showBg();"  class="info_img"><img src="<?=$headphoto?>" title="点击修改头像"/></a></div>
			<ul>
				<li><a href="gmem.html">订单中心</a></li>
				<li><a href="gmem_Data.html">个人资料</a></li>
				<li><a href="gmem_pass.html">修改密码</a></li>
				<!-- <li><a href="javascript:" id="gToplogout" class="logout">安全退出</a></li> -->
				
			</ul>
		</div>
		<div class="mem_right pass">
			<div  class="hcon"></div>
			<div class="mem_data">
				<p class="img_p">	
					<img src="<?=$headphoto?>" alt=""/>
					<a href="javascript:showBg();">修改头像</a>
				</p> 
				<p>	
					<b>账号：</b><span><?=$_SESSION['account']?></span>
				</p>
				<!-- <p>	
					<b>绑定手机：</b><span id="mob"><?=$m_info['mobile']?></span> <a href="javascript:void(0);" onclick="chMob()"<?=$chmob?> class="infsp2">修改</a>
				</p>
				 -->
			</div>
			<!--修改绑定手机遮罩-->
			<div id="chmob">
				<h3><label>修改绑定手机</label><button onclick="chMob();" class="close" type="button">X</button></h3>
				<span class="txt">绑定手机号：</span>
				<span id="_mob"><?=$m_info['mobile']?></span>
				<button type="button" id="" onclick="Vcode()">获取验证码</button><br />
				<span class="txt"></span>
				<input type="text" id="mobile" />
				<button type="button" id="btn" onclick="Vcode()">获取验证码</button><br />
				<span class="txt">验证码：</span>
				<input type="text" id="yzm" />
				<span class="err"></span>
				<div>
					<span class="txt">账户密码：</span>
					<input type="password" id="ps" />
					<span class="err"></span>
				</div>
				<button type="button" class="sub" onclick="sub_c()">确认修改</button>
				<a href="javascript:void(0);" onclick="yzali()" title="验证所填写的支付宝账户是否正确">验证支付宝账户</a>
			</div>
		</div>
	</div>
	<?php include("ggfoot_m.php");?>
<script type="text/javascript">
/*修改头像*/
function uploadevent(status,picUrl,callbackdata){
    closeBg();
    status += ''; 
    switch(status){
     case '1':
		var time = new Date().getTime();
		// var filename162 = picUrl+'_162.jpg';
        // alert(filename162);
        document.getElementById('user_photo').src=""+picUrl+"";
		 window.parent.location='/new/d/shops/gmem_Data.html';
        break;
    case '-1':
        window.parent.location='/new/d/shops/gmem_Data.html';
        break;
    default:
		window.parent.location='/new/d/shops/gmem_Data.html';
    } 
}

/*修改头像遮罩*/
function showBg() { 
	var bh = $("html").height(); 
	var bw = $("html").width(); 
	$("#fullbg").css({ 
	height:bh, 
	width:bw, 
	display:"block" 
	}); 
	$("#dialog").show(); 
} 
function closeBg() { 
    $("#fullbg,#dialog").hide(); 
} 


/*修改手机号码*/
var t=60;
var ds;
var type;
function chMob(a){
	if(a){
		if(!$('#_mob').html()){
			alert('请先绑定手机号');
			return false;
		}
		type='ali';
		$('#chmob h3 label').html('修改支付宝账号');
		$('#chmob span').eq(0).show().end().eq(2).html('新支付宝账号：');
		$('#_mob').show();
		$('#chmob button').eq(1).attr('id','btn').show().end().eq(2).attr('id','').hide();
		$('#chmob div').hide();
		$('#chmob a').show();
	}
	else{
		type='mob';
		$('#chmob h3 label').html('修改绑定手机');
		$('#chmob span').eq(0).hide().end().eq(2).html('新手机号码：');
		$('#_mob').hide();
		$('#chmob button').eq(1).attr('id','').hide().end().eq(2).attr('id','btn').show();
		$('#chmob div').show();
		$('#chmob a').hide();
	}
	$('#mobile').val('');
	$('#yzm').val('');
	$('#mask').toggle();
	$('#chmob').toggle();
	return false;
}
function Vcode(){
	if(type=='mob'){
		var res=$.ajax({url:"../call/chmob.php", data:{ act:'chH', mobile:$('#mobile').val()}, async:false}).responseText;
		if(res){
			alert(res);
			return false;
		}
	}
	ds=self.setInterval("countdown()",1000);
	$('#btn').attr('disabled',true);
	var mobile=type=='mob'?$('#mobile').val():$('#mob').html();
	$.getJSON("../call/jh_mem.php", { action:'SendVcode', stype:'phone', mobile:mobile }, function(json){
		if(json['status']!='ok'){alert(json['msg']);}
		else{alert('验证码已发送!')}
	});

}
function countdown(){
	$('#btn').html('获取验证码('+t+')');
	t--;
	if(!t){
		window.clearInterval(ds);
		$('#btn').html('获取验证码').attr('disabled',false);
		t=60;
	}
}
function sub_c(){
	$.getJSON("../call/jh_mem.php", { action:'VerifyVcode', vcode:$('#yzm').val() }, function(json){
		if(json['status']=='ok'){
			if(type=='mob'){
				var res=$.ajax({url:"../call/chmob.php", data:{ act:'chM', mobile:$('#mobile').val(), ps:hex_md5($('#ps').val())}, async:false}).responseText;
				if(res!="ok"){$('#ps').next().html(res);}
				else{
					alert('手机号修改成功!');
					window.location.reload();
				}
			}
			else{
				var res=$.ajax({url:"../call/chmob.php", data:{ act:'chA', alipay:$('#mobile').val()}, async:false}).responseText;
				if(res!="ok"){$('#yzm').next().html(res);}
				else{
					alert('支付宝账号修改成功!');
					window.location.reload();
				}
			}
		}
		else{$('#yzm').next().html(json['msg']);}
	});
}
function yzali(){
	var mob=$('#mobile').val();
	if(mob){
		window.open('rerified.html?ali='+mob,'_blank');
	}
	else{	
		alert('请填写支付宝账号');
	}
}
<?if(isset($_REQUEST["b"])){?>
$(document).ready(function(){
	chMob(1);
});
<?}?>
</script>
</body>
</html>
<div id="fullbg"></div> 
<div id="dialog"> 
<p class="close"><a href="#" onclick="closeBg();">X</a>  
<div >
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
	codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
	WIDTH="650" HEIGHT="450" id="myMovieName">
	<PARAM NAME=movie VALUE="avatar.swf">
	<PARAM NAME=quality VALUE=high>
	<PARAM NAME=bgcolor VALUE=#FFFFFF>
	<param name="flashvars" value="imgUrl=./default.jpg&uploadUrl=./upfile.php&uploadSrc=false" />
	<EMBED src="avatar.swf" quality=high bgcolor=#FFFFFF WIDTH="650" HEIGHT="450" wmode="transparent" flashVars="imgUrl=./default.jpg&uploadUrl=./upfile.php&uploadSrc=false"
	NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash" allowScriptAccess="always"
	PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
	</EMBED>
</OBJECT>  
